package com.hnhcyy.goods.pojo;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.hnhcyy.goods.properties.ImageConfig;

/**
 * 即将到货商品
 */
public class GoodsPre{
	
	/**
	 * 商品ID
	 */	
	@JsonInclude(Include.NON_NULL)
	private String spid;
	/**
	 * 商家ID
	 */
	@JsonInclude(Include.NON_NULL)
	private Integer sjid;	
	/**
	 * 商品名称
	 */
	@JsonInclude(Include.NON_NULL)
	private String spmch;
	/**
	 * 生产厂家
	 */
	@JsonInclude(Include.NON_NULL)
	private String shpchd;
	/**
	 * 商品规格
	 */
	@JsonInclude(Include.NON_NULL)
	private String shpgg;
	/**
	 * 是否显示
	 */
	@JsonInclude(Include.NON_NULL)
	private Boolean isvisible;	
	/**
	 * 图片
	 */
	@JsonInclude(Include.NON_NULL)
	private String picture;
	/**
	 * 显示顺序
	 */
	@JsonInclude(Include.NON_NULL)
	private Integer findex;	
	/**
	 * 预计到货日期
	 */
	@JsonInclude(Include.NON_NULL)
	private Date preDate;
	/**
	 * 创建人
	 */
	@JsonInclude(Include.NON_NULL)
	private String creator;
	
	/**
	 * 创建时间
	 */
	@JsonInclude(Include.NON_NULL)
	private Date created;	
	
	
	public String getSpid() {
		return spid;
	}

	public void setSpid(String spid) {
		this.spid = spid;
	}

	public Integer getSjid() {
		return sjid;
	}

	public void setSjid(Integer sjid) {
		this.sjid = sjid;
	}

	public String getSpmch() {
		return spmch;
	}

	public void setSpmch(String spmch) {
		this.spmch = spmch;
	}

	public String getShpchd() {
		return shpchd;
	}

	public void setShpchd(String shpchd) {
		this.shpchd = shpchd;
	}

	public String getShpgg() {
		return shpgg;
	}

	public void setShpgg(String shpgg) {
		this.shpgg = shpgg;
	}

	public Boolean getIsvisible() {
		return isvisible;
	}

	public void setIsvisible(Boolean isvisible) {
		this.isvisible = isvisible;
	}

	public String getPicture() {
		return picture;
	}

	public void setPicture(String picture) {
		this.picture = picture;
	}

	public Integer getFindex() {
		return findex;
	}

	public void setFindex(Integer findex) {
		this.findex = findex;
	}

	public Date getPreDate() {
		return preDate;
	}

	public void setPreDate(Date preDate) {
		this.preDate = preDate;
	}

	public String getCreator() {
		return creator;
	}

	public void setCreator(String creator) {
		this.creator = creator;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public String getMinPicture() {
		if(spid == null) {
			return null;
		}
		return ImageConfig.goodsPicturePrefix + spid + "/10.jpg";
	}
	
	/**
	 * 获取图片列表
	 */
	public List<String> getPictureList()
	{
		if(this.picture == null) {
			return null;
		}
		try {
			List<String> picList = new ArrayList<String>();
			for(int i = 0, length = Math.min(picture.length(), 10); i < length; i++){
				if(this.picture.substring(i, i + 1).equalsIgnoreCase("1")){
					picList.add(ImageConfig.goodsPicturePrefix + spid + "/" + i + ".jpg");
				}
			}
			return picList;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	} 
	
}
